//
//  NSArray+MKUI.h
//  MKUI
//
//  Created by 苏尚进 on 2022/5/9.
//  Copyright © 2022 moon. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSArray<ObjectType> (MKUI)

/// 扣除otherArray中的所有元素，返回新的数组:result=self-otherArray
/// @param otherArray 被扣除元素的数组
- (NSArray<ObjectType> *)mk_removeObjectsInArray:(NSArray<ObjectType> *)otherArray;

/// 对数组中的每个元素进行映射变换，返回新的数组
/// @param block 变换block，当返回nil时，代表不添加
- (NSArray *)mk_map:(NS_NOESCAPE id _Nullable(^ _Nullable)(__kindof ObjectType obj))block;
- (NSArray *)mk_mapWithIndex:(NS_NOESCAPE id _Nullable(^ _Nullable)(__kindof ObjectType obj,NSInteger index))block;

/// 对数组中的每个元素进行变换，变换block返回dict，然后将所有的dict合并返回
/// @param block 变换block，返回dict
- (NSDictionary *)mk_mapDictionary:(NS_NOESCAPE NSDictionary * _Nullable(^ _Nullable)(__kindof ObjectType obj))block;
- (NSDictionary *)mk_mapDictionaryWithIndex:(NS_NOESCAPE NSDictionary * _Nullable(^ _Nullable)(__kindof ObjectType obj,NSInteger index))block;

- (nullable id)mk_reduce:(NS_NOESCAPE id _Nullable(^ _Nullable)(NSInteger index,__kindof ObjectType obj,id _Nullable result,BOOL *stop))block first:(nullable id)first;
@end

@interface NSMutableArray<ObjectType> (MKUI)
/// 在指定的位置后面，插入多笔数据
/// - Parameters:
///   - objects: 待插入的数组
///   - index: 指定的位置
- (void)mk_insertObjects:(NSArray<ObjectType> *)objects afterIndex:(NSInteger)index;

/// 在数组头部插入多笔数据
/// - Parameter objects: 待插入的数组
- (void)mk_insertObjectsToTop:(NSArray<ObjectType> *)objects;
@end
NS_ASSUME_NONNULL_END
